*********************************************************************************																		       ** 							VAP								 				   **								     									       ********************************************************************************** -----> This do-file: All tables and graphs relying on manual coding of tweets ********************************************************************************set more offclear allset matsize 3000set maxvar 10000************************************* Path if "`c(username)'"=="Juan S. Morales" | "`c(username)'"=="jmorales" {	global PathData = "C:/Users/`c(username)'/Dropbox/adamowicz/4_Draft/CPS_FINAL_submission/Data/"	global PathFig = "C:/Users/`c(username)'/Dropbox/adamowicz/4_Draft/CPS_FINAL_submission/Figures/"	global PathTab = "C:/Users/`c(username)'/Dropbox/adamowicz/4_Draft/CPS_FINAL_submission/Tables/"	}else { 	global PathData = "/Users/JNG/Dropbox/adamowicz/4_Draft/CPS_FINAL_submission/Data/"	global PathFig = "/Users/JNG/Dropbox/adamowicz/4_Draft/CPS_FINAL_submission/Figures/"	global PathTab = "/Users/JNG/Dropbox/adamowicz/4_Draft/CPS_FINAL_submission/Tables/"	} use "${PathData}sept2021export.dta", cleargen date = substr(created_at,1,10)gen month = substr(date,6,2)gen year = substr(date,1,4)gen day = substr(date,9,2)gen hour = substr(created_at,12,2)destring(month), replacedestring(year), replacedestring(day), replacedestring(hour), replacegen time = (year-2012)*12 + monthgen timeD = (year-2012)*365 + (month==2)*31 + (month==3)*(31+28) + (month==4)*(31*2 + 28) + (month==5)*(31*2 + 28 +30) + (month==6)*(31*3 + 28 +30) + (month==7)*(31*3 + 28 + 30*2) + (month==8)*(31*4 + 28 + 30*2) + (month==9)*(31*5 + 28 + 30*2) + (month==10)*(31*5 + 28 + 30*3) + (month==11)*(31*6 + 28 + 30*3) + (month==12)*(31*6 + 28 + 30*4) + day + 1*((month>2 & year==2012)|(year>2012))gen week = round(timeD/7)gen date2 = mdy(month, day, year)gen text_l = lower(text)replace text = text_ldrop text_lreplace text = subinstr(text, "á", "a",.) replace text = subinstr(text, "é", "e",.) replace text = subinstr(text, "í", "i",.) replace text = subinstr(text, "ó", "o",.) replace text = subinstr(text, "ú", "u",.)replace text = subinstr(text, "ñ", "nh",.)replace text = subinstr(text, ",", " ",.)replace text = subinstr(text, `"""',  "", .)replace text = subinstr(text, ".", " ",.) replace text = subinstr(text, "-", " ",.)replace text = subinstr(text, "!", " ",.) replace text = subinstr(text, "/", " ",.)replace text = subinstr(text, "…", " ",.)replace text = subinstr(text, ":", " ",.)replace text = subinstr(text, ";", " ",.)* replace text = subinstr(text, "#", "",.)* replace text = subinstr(text, "@", "",.)forvalues i = 1(1)7 {	replace text = subinstr(text, "  ", " ",.)}capture drop gg_*gen gg_hashtag = strpos(text, "#")>0gen gg_at = strpos(text, "@")>0gen gg_reply = in_reply_to_user!=""*at zero for this datasetgen gg_rt = strpos(text, "rt ") == 1gen gg_http = strpos(text, "http")>0***merge MP data****merge m:m screen_name using "${PathData}mp.dta"rename _merge mergeMP***** Coding VARIABLES (general) *****gen dOfWeek = mod(date2,7)replace dOfWeek = dOfWeek - 2replace dOfWeek = dOfWeek + 7 if dOfWeek<1drop gg_rtgen gg_rt = strpos(text, "rt ") == 1gen gg_adamowicz = strpos(text, "adamowicz")>0gen log_rt = log(rt_count + 1)gen log_fav = log(favcount + 1)gen log_engagement = log(rt_count + favcount + 1)egen userid = group(screen_name)bysort date2 userid: gen N_du = _N**** Coding TREATMENT (Adamowicz) *******	gen dayC_ada = date2 - 21562gen dayC_sq_ada = dayC_ada*dayC_adagen dayC_cu_ada = dayC_ada*dayC_ada*dayC_adagen post_ada = date2>=21562gen dayC_post_ada = dayC_ada*post_adagen dayC_sq_post_ada = dayC_sq_ada*post_adagen dayC_cu_post_ada = dayC_cu_ada*post_adagen dayC_opos_ada = dayC_ada*oppositiongen dayC_sq_opos_ada = dayC_sq_ada*oppositiongen dayC_cu_opos_ada = dayC_cu_ada*oppositiongen dayC_opos_post_ada = dayC_ada*opposition*post_adagen dayC_sq_opos_post_ada = dayC_sq_ada*opposition*post_adagen dayC_cu_opos_post_ada = dayC_cu_ada*opposition*post_adagen post_opo_ada = post_ada*oppositiongen post_gob_ada = post_ada*governmentgen hour_sq = hour*hourgen hour_cu = hour*hour*hourbysort userid: gen n_u = _ngen ffd_dayssinceE_ada = 99999gen ffd_targetdate_ada = 21562foreach targetdate in 21562 {	replace ffd_dayssinceE_ada = (date2-`targetdate') if (abs(date2-`targetdate')<=abs(ffd_dayssinceE_ada))	replace ffd_targetdate_ada = `targetdate' if (abs(date2-`targetdate')<=abs(ffd_dayssinceE_ada))}gen event_days_ada = date2-21562gen timeWindow0_ada = ffd_dayssinceE_ada>-3 & ffd_dayssinceE_ada<2gen timeWindow1_ada = ffd_dayssinceE_ada>-6 & ffd_dayssinceE_ada<5gen timeWindow2_ada = ffd_dayssinceE_ada>-11 & ffd_dayssinceE_ada<10gen timeWindow3_ada = ffd_dayssinceE_ada>-16 & ffd_dayssinceE_ada<15gen timeWindow4_ada = ffd_dayssinceE_ada>-21 & ffd_dayssinceE_ada<20gen timeWindow5_ada = ffd_dayssinceE_ada>-31 & ffd_dayssinceE_ada<30**** Coding OTHER MENTIONS *******replace text = " " + textgen opMentions = strpos(text," rzd") + strpos(text," min ") + strpos(text,"minist") + strpos(text,"wicemin") + strpos(text,"pis ") + strpos(text,"tvp") + strpos(text,"andruszkiewicz") + strpos(text,"berni_krynick") + strpos(text,"budet") + strpos(text,"premier") + strpos(text,"morawieck") + strpos(text,"pisowsk") + strpos(text,"macierewicz") + strpos(text,"kaczysk") + strpos(text," msz ") + strpos(text,"tygodnik_sieci") + strpos(text,"smolesk") + strpos(text,"misiewicz") + strpos(text,"tasmykaczynsk") + strpos(text,"glapiski") + strpos(text,"glapinski") + strpos(text,"szydo") + strpos(text,"ziobro") + strpos(text,"zieliski") + strpos(text,"gowin") + strpos(text,"jbrudzinski") + strpos(text,"drelich") + strpos(text,"terlecki") + strpos(text,"sdownictw") + strpos(text,"pisorgpl") + strpos(text," nbp ") + strpos(text,"wicemarsz") + strpos(text," cba ") + strpos(text,"patryk jaki") + strpos(text,"policj") + strpos(text,"czaputowicz") + strpos(text,"gliski")replace opMentions = opMentions>0gen govMentions = strpos(text," opozycj") + strpos(text,"bzdrojewski") + strpos(text," lewic") + strpos(text,"olejnik") + strpos(text," lewicow") + strpos(text," biedro") + strpos(text," lewac") + strpos(text," psl_") + strpos(text," psl ") + strpos(text,"gazwyb") + strpos(text," nowick") + strpos(text," sikorsk") + strpos(text,"schetyn") + strpos(text," neuman") + strpos(text,"tomasz_lis") + strpos(text,"tomasz lis") + strpos(text," lis_tomasz") + strpos(text," tusk") + strpos(text," platform") + strpos(text,"trzaskowski_") + strpos(text,"platforma_org") + strpos(text,"klubnauer") + strpos(text," gw_") + strpos(text,"gazetawyborcza") + strpos(text,"tvn24")replace govMentions = govMentions>0replace govMentions = govMentions + strpos(text,"platforma_org")>0replace govMentions = govMentions + strpos(text,"tomaszsiemoniak")>0replace govMentions = govMentions + strpos(text,"arlukowicz")>0replace govMentions = govMentions + strpos(text,"bbudka")>0replace govMentions = govMentions + strpos(text,"andrzejhalicki")>0replace govMentions = govMentions + strpos(text,"slawekneumann")>0replace govMentions = govMentions + strpos(text,"schetynadlapo")>0replace govMentions = govMentions + strpos(text,"mkierwinski")>0replace govMentions = govMentions + strpos(text,"jangrabiec")>0replace govMentions = govMentions + strpos(text,"achybicka")>0replace govMentions = govMentions + strpos(text,"protasiewiczj")>0replace govMentions = govMentions + strpos(text,"zpawlowicz")>0replace govMentions = govMentions + strpos(text,"trzaskowski_")>0replace govMentions = govMentions + strpos(text,"tomaszlenz")>0replace govMentions = govMentions + strpos(text,"hannagw")>0replace govMentions = govMentions + strpos(text,"asia_mucha")>0replace govMentions = govMentions + strpos(text,"niesiolowskis")>0replace govMentions = govMentions + strpos(text,"bbukiewicz")>0replace govMentions = govMentions + strpos(text,"c_grabarczyk")>0replace govMentions = govMentions + strpos(text,"ikatarasinska")>0replace govMentions = govMentions + strpos(text,"ctomczyk")>0replace govMentions = govMentions + strpos(text,"sowamarek")>0replace govMentions = govMentions + strpos(text,"ireneuszras")>0replace govMentions = govMentions + strpos(text,"kopacz_ewa")>0replace govMentions = govMentions + strpos(text,"m_k_blonska")>0replace govMentions = govMentions + strpos(text,"adam_korol")>0replace govMentions = govMentions + strpos(text,"pomaska")>0replace govMentions = govMentions + strpos(text,"henryka_henia50")>0replace govMentions = govMentions + strpos(text,"miroslawanykiel")>0replace govMentions = govMentions + strpos(text,"marianzembala")>0replace govMentions = govMentions + strpos(text,"urszulaaugustyn")>0replace govMentions = govMentions + strpos(text,"kr_szumilas")>0replace govMentions = govMentions + strpos(text,"okladrewnowicz")>0replace govMentions = govMentions + strpos(text,"mswitczak")>0replace govMentions = govMentions + strpos(text,"jakubrutnicki")>0replace govMentions = govMentions + strpos(text,"mjanyska")>0replace govMentions = govMentions + strpos(text,"ziolkowskiszym")>0replace govMentions = govMentions + strpos(text,"waldydzikowski")>0replace govMentions = govMentions + strpos(text,"slawomirnitras")>0replace govMentions = govMentions + strpos(text,"krzysztofbrejza")>0replace govMentions = govMentions + strpos(text,"arkadiuszmyrcha")>0replace govMentions = govMentions + strpos(text,"mwielichowska")>0replace govMentions = govMentions + strpos(text,"gajewska_kinga")>0replace govMentions = govMentions + strpos(text,"newsplatforma")>0replace govMentions = govMentions + strpos(text,"grzegorzfurgo")>0replace govMentions = govMentions + strpos(text,"bborusewicz")>0replace govMentions = govMentions + strpos(text,"tomaszsiemoniak")>0replace govMentions = govMentions + strpos(text,"rtyszkiewicz")>0replace govMentions = govMentions + strpos(text,"jaroslawduda")>0replace govMentions = govMentions + strpos(text,"zdzislaw_gawlik")>0replace govMentions = govMentions + strpos(text,"arturgierada")>0replace govMentions = govMentions + strpos(text,"a_marchewka")>0replace govMentions = govMentions + strpos(text,"jacek_protas")>0replace govMentions = govMentions + strpos(text,"wojciechsaluga")>0replace govMentions = govMentions + strpos(text,"wslugocki")>0replace govMentions = govMentions + strpos(text,"hannazdanowska")>0replace govMentions = govMentions + strpos(text,"prezydentzuk")>0replace govMentions = govMentions + strpos(text,"izabela_debska")>0replace govMentions = govMentions + strpos(text,"tadeuszzwiefka")>0replace govMentions = govMentions + strpos(text,"donaldtusk")>0replace opMentions = opMentions + strpos(text,"piotr_naimski")>0replace opMentions = opMentions + strpos(text,"pisorgpl")>0replace opMentions = opMentions + strpos(text,"morawieckim")>0replace opMentions = opMentions + strpos(text,"jbrudzinski")>0replace opMentions = opMentions + strpos(text,"patrykjaki")>0replace opMentions = opMentions + strpos(text,"andzyberto")>0replace opMentions = opMentions + strpos(text,"kurskipl")>0replace opMentions = opMentions + strpos(text,"piotrglinski")>0replace opMentions = opMentions + strpos(text,"jaroslaw_gowin")>0replace opMentions = opMentions + strpos(text,"stkarczewski")>0replace opMentions = opMentions + strpos(text,"marekkuchcinski")>0replace opMentions = opMentions + strpos(text,"beataszydlo")>0replace opMentions = opMentions + strpos(text,"beatamk")>0replace opMentions = opMentions + strpos(text,"e_rafalska")>0replace opMentions = opMentions + strpos(text,"krystpawlowicz")>0replace opMentions = opMentions + strpos(text,"ziobropl")>0replace opMentions = opMentions + strpos(text,"beatakempa_kprm")>0replace opMentions = opMentions + strpos(text,"mblaszczak")>0replace opMentions = opMentions + strpos(text,"macierewicz_a")>0replace opMentions = opMentions + strpos(text,"elzbietawitek")>0replace opMentions = opMentions + strpos(text,"_annazalewska")>0replace opMentions = opMentions + strpos(text,"michaldworczyk")>0replace opMentions = opMentions + strpos(text,"latostomasz")>0replace opMentions = opMentions + strpos(text,"slawzawislak")>0replace opMentions = opMentions + strpos(text,"wassermann_ma")>0replace opMentions = opMentions + strpos(text,"arekmularczyk")>0replace opMentions = opMentions + strpos(text,"w_bernacki")>0replace opMentions = opMentions + strpos(text,"mareksuski")>0replace opMentions = opMentions + strpos(text,"akosztowniak")>0replace opMentions = opMentions + strpos(text,"minenergii")>0replace opMentions = opMentions + strpos(text,"a_czartoryski")>0replace opMentions = opMentions + strpos(text,"mariuszkaminsk")>0replace opMentions = opMentions + strpos(text,"sasinjacek ?")>0replace opMentions = opMentions + strpos(text,"bogdan_rzonca")>0replace opMentions = opMentions + strpos(text,"andrzejszlachta")>0replace opMentions = opMentions + strpos(text,"mrirw_gov_pl")>0replace opMentions = opMentions + strpos(text,"d_piontkowski")>0replace opMentions = opMentions + strpos(text,"mkidn_gov_pl")>0replace opMentions = opMentions + strpos(text,"stanislaw_szwed")>0replace opMentions = opMentions + strpos(text,"szymongizynski")>0replace opMentions = opMentions + strpos(text,"izabelakloc")>0replace opMentions = opMentions + strpos(text,"andrzejduda")>0replace opMentions = opMentions + strpos(text,"annamkrupka")>0replace opMentions = opMentions + strpos(text,"iwonaarent")>0replace opMentions = opMentions + strpos(text,"joannalichocka")>0replace opMentions = opMentions + strpos(text,"witoldczarneck3")>0replace opMentions = opMentions + strpos(text,"tadeuszdziuba")>0replace opMentions = opMentions + strpos(text,"zagorskimarek")>0replace opMentions = opMentions + strpos(text,"marekgrobarczyk")>0replace opMentions = opMentions + strpos(text,"amadamczyk")>0replace opMentions = opMentions + strpos(text,"jerzykwiecinski")>0replace opMentions = opMentions + strpos(text,"jemilewicz")>0replace opMentions = opMentions + strpos(text,"witoldbanka")>0replace opMentions = opMentions + strpos(text,"jczaputowicz")>0replace opMentions = opMentions + strpos(text,"szumowskilukasz")>0replace opMentions = opMentions + strpos(text,"j_kopcinska")>0replace opMentions = opMentions + strpos(text,"profkarski")>0replace opMentions = opMentions + strpos(text,"ryszardterlecki")>0replace opMentions = opMentions + strpos(text,"r_czarnecki")>0replace opMentions = opMentions + strpos(text,"grzegorzczelej")>0replace opMentions = opMentions + strpos(text,"anita_cz")>0replace opMentions = opMentions + strpos(text,"ministerjurgiel")>0replace opMentions = opMentions + strpos(text,"cymanskitadeusz")>0replace opMentions = opMentions + strpos(text,"jacekzalek")>0gen mentionOther = (opMentions & opposition) | (govMentions & government)replace mentionOther = 0 if mentionOther == .gen post_mention_ada = post_ada*mentionOthergen post_opo_mention_ada = post_ada*opposition*mentionOthergen opo_mention = opposition*mentionOthergen mention_ada = mentionOther*gg_adamowiczgen mention_opo_ada= mentionOther*gg_adamowicz*oppositiongen post_mp_ada = post_ada*mpgen post_opo_mp = post_opo_ada*mp**** negative campaigning manually coded ****replace humor = 0 if humor==.replace threat = 0 if threat==.replace criticism = 0 if criticism==.label variable humor "Humorous criticism"label variable criticism "Explicit criticism"label variable threat "Threat"gen post_humor = post_ada * humorgen post_threat = post_ada * threatgen post_criticism = post_ada * criticismlabel variable post_humor "Post x Humorous criticism"label variable post_criticism "Post x Explicit criticism"label variable post_threat "Post x Threat"label variable post_opo_ada "Post x Opposition"label variable opposition "Party"label define select 0 "Government" 1 "Opposition" label values opposition selectlabel variable post_ada "Attack"label define select2 0 "Pre" 1 "Post" label values post_ada select2*** Figure A8 ***cibar criticism if !gg_adamowicz & mp, over1(post_ada) over2(opposition)cibar threat if !gg_adamowicz & mp, over1(post_ada) over2(opposition)cibar humor if !gg_adamowicz & mp, over1(post_ada) over2(opposition)cibar mentionOther if !gg_adamowicz & mp, over1(post_ada) over2(opposition) **** Table A9  ****eststo cleareststo, title("Engagement"): reghdfe log_engagement post_opo_ada humor post_humor criticism post_criticism threat post_threat hour_sq hour gg_hashtag gg_at gg_reply gg_rt gg_http if timeWindow3_ada & !gg_rt, cl(userid) abs(userid date2)estadd local dFE = "Yes"estadd local pFE = "Yes"estadd local controls = "Yes"eststo, title("Retweets"): reghdfe log_rt post_opo_ada humor post_humor criticism post_criticism threat post_threat hour_sq hour gg_hashtag gg_at gg_reply gg_rt gg_http if timeWindow3_ada & !gg_rt, cl(userid) abs(userid date2)estadd local dFE = "Yes"estadd local pFE = "Yes"estadd local controls = "Yes"eststo, title("Likes"): reghdfe log_fav post_opo_ada humor post_humor criticism post_criticism threat post_threat hour_sq hour gg_hashtag gg_at gg_reply gg_rt gg_http if timeWindow3_ada & !gg_rt, cl(userid) abs(userid date2)estadd local dFE = "Yes"estadd local pFE = "Yes"estadd local controls = "Yes"esttab using "${PathTab}TableA9.tex", b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) keep(post_opo_ada humor post_humor criticism post_criticism threat post_threat) stats(N pFE dFE controls, fmt(0) labels("N" "Day FE" "Politician FE" "Controls")) label nodepvar mtitles title("Violent attack and Twitter engagement: Negative campaiging effect") replace nonotes postfoot(" ")**** Table A20 ****label variable opposition "Opposition (dummy)"label variable log_rt "Retweets (log)"label variable log_fav "Likes (log)"label variable log_engagement "Engagement (log)"gen totaleng = favcount + rt_countlabel variable rt_count "Retweets"label variable favcount "Likes"label variable totaleng "Engagement"replace humor = 0 if humor==.replace threat = 0 if threat==.replace criticism = 0 if criticism==.label variable humor "Humorous criticism (dummy)"label variable criticism "Explicit criticism (dummy)"label variable threat "Threat (dummy)"label variable mentionOther "Mention rival (dummy)"label variable post_ada "Post assassination (dummy)"sutex opposition log_rt log_fav log_engagement rt_count favcount totaleng humor threat criticism mentionOther post_ada, minmax labels title("Summary statistics for tweets \label{tab:taba20}") file("${PathTab}TableA20.tex") replace